
PM_FUNC_NORM_ATTRIB DHudEventMessage( Int:iPlayer, String:szMessage[], ... )
{
	new String:szFinalMessage[ 128 ];
	vformat( szFinalMessage, charsmax(szFinalMessage), szMessage, 3 );

	new Int:iPlayers[ 32 ], Int:iPlayerNum;
	if ( !iPlayer )
		get_players( iPlayers, iPlayerNum );
	else
		iPlayers[ iPlayerNum++ ] = iPlayer;

	for ( new Int:i, Int:iTempPlayer, Int:iOffsetY, Int:iHudColor; i < iPlayerNum; i++ )
	{
		iTempPlayer = iPlayers[ i ];

		iOffsetY = PlayerGetInfo( iTempPlayer, PINFO_DHUD_OFFSET );
		iHudColor = PlayerGetInfo( iTempPlayer, PINFO_HUD_COLOR );
		if ( iHudColor == HUD_TEAM_BASED )
			iHudColor = _:cs_get_user_team( iTempPlayer );

		DHudMessage( iTempPlayer,
			.iRed = cHudColors[ iHudColor ][ 0 ],
			.iGreen = cHudColors[ iHudColor ][ 1 ],
			.iBlue = cHudColors[ iHudColor ][ 2 ],
			.fX = ( 0.01 * PlayerGetInfo( iTempPlayer, PINFO_DHUDPOS_X ) ),
			.fY = ( 0.01 * PlayerGetInfo( iTempPlayer, PINFO_DHUDPOS_Y ) ) + ( 0.05 * iOffsetY ),
			.iEffects = 1,
			.fEffectsTime = 1.0,
			.fHoldTime = 10.0,
			.fFadeInTime = 0.1,
			.fFadeOutTime = 1.5,
			.szMessage = szFinalMessage
		);

		PlayerSetInfo( iTempPlayer, PINFO_DHUD_OFFSET, ( iOffsetY + 1 ) % 8 );
	}

	client_print( iPlayer, print_chat, "[PokeMod] %s", szFinalMessage );
}

PM_FUNC_NORM_ATTRIB DHudMessage( Int:iIndex, Int:iRed = 0, Int:iGreen = 160, Int:iBlue = 0, Float:fX = -1.0, Float:fY = 0.65, Int:iEffects = 2, Float:fEffectsTime = 6.0, Float:fHoldTime = 3.0, Float:fFadeInTime = 0.1, Float:fFadeOutTime = 1.5, const String:szMessage[] )
{
	#if !defined clamp_byte
		#define clamp_byte(%1)       ( clamp( %1, 0, 255 ) )
	#endif
	#if !defined pack_color
		#define pack_color(%1,%2,%3) ( %3 + ( %2 << 8 ) + ( %1 << 16 ) )
	#endif

	message_begin( ( iIndex ? MSG_ONE_UNRELIABLE : MSG_BROADCAST ), SVC_DIRECTOR, _, iIndex );
	{
		write_byte( strlen( szMessage ) + 31 );
		write_byte( DRC_CMD_MESSAGE );
		write_byte( iEffects );
		write_long( pack_color( clamp_byte( iRed ), clamp_byte( iGreen ), clamp_byte( iBlue ) ) );
		write_long( _:fX );
		write_long( _:fY );
		write_long( _:fFadeInTime );
		write_long( _:fFadeOutTime );
		write_long( _:fHoldTime );
		write_long( _:fEffectsTime );
		write_string( szMessage );
	}
	message_end();
}



